home *** CD-ROM | disk | FTP | other *** search
/ 9-Digit Zip Code Directory / 9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO / z4src.zip / MYTSTVW.CPP < prev    next >
C/C++ Source or Header  |  1995-09-21  |  4KB  |  167 lines

  1. // mytstvw.cpp : implementation of the CMytestView class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "mytest2.h"
  6.  
  7. #include "mytstdoc.h"
  8. #include "mytstvw.h"
  9. #include "inqone.h"
  10. #include "z4.h"
  11.  
  12. #ifdef _DEBUG
  13. #undef THIS_FILE
  14. static char BASED_CODE THIS_FILE[] = __FILE__;
  15. #endif
  16.  
  17. Z4_INQ z4_inq;
  18.  
  19. /////////////////////////////////////////////////////////////////////////////
  20. // CMytestView
  21.  
  22. IMPLEMENT_DYNCREATE(CMytestView, CView);
  23.  
  24. BEGIN_MESSAGE_MAP(CMytestView, CView)
  25.     //{{AFX_MSG_MAP(CMytestView)
  26.     ON_WM_LBUTTONDOWN()
  27.     //}}AFX_MSG_MAP
  28. END_MESSAGE_MAP()
  29.  
  30. /////////////////////////////////////////////////////////////////////////////
  31. // CMytestView construction/destruction
  32.  
  33. CMytestView::CMytestView()
  34. {
  35.     // TODO: add construction code here
  36. }
  37.  
  38. CMytestView::~CMytestView()
  39. {
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CMytestView drawing
  44.  
  45. void CMytestView::OnDraw(CDC* pDC)
  46. {
  47.     //CMytestDoc* pDoc = GetDocument();
  48.     //ASSERT_VALID(pDoc);
  49.  
  50.     pDC->TextOut(0,0,"Press left mouse button. . .");
  51. }
  52.  
  53. /////////////////////////////////////////////////////////////////////////////
  54. // CMytestView diagnostics
  55.  
  56. #ifdef _DEBUG
  57. void CMytestView::AssertValid() const
  58. {
  59.     CView::AssertValid();
  60. }
  61.  
  62. void CMytestView::Dump(CDumpContext& dc) const
  63. {
  64.     CView::Dump(dc);
  65. }
  66.  
  67. CMytestDoc* CMytestView::GetDocument() // non-debug version is inline
  68. {
  69.     ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMytestDoc)));
  70.     return (CMytestDoc*)m_pDocument;
  71. }
  72. #endif //_DEBUG
  73.  
  74. /////////////////////////////////////////////////////////////////////////
  75. /////////// configuration file lookup
  76.  
  77. void Initialize(void)
  78. {
  79.         
  80.         if (!Z4_INQ::Start())
  81.         {
  82.         Error("There is a problem accessing the data files.\n"
  83.         "Please verify that the program is configured correctly.");
  84.         }
  85.  
  86.         return;
  87. }
  88.  
  89.  
  90. /////////////////////////////////////////////////////////////////////////////
  91. ////  sresults module code
  92.  
  93. VOID SetResults(void)
  94. {
  95.      
  96.         if (z4_inq.result == Z4_RESULT_FAILURE)
  97.                 {
  98.                 Error("Inquiry not possible.");
  99.                 }
  100.         else if (z4_inq.result == Z4_RESULT_ABORT)
  101.                 {
  102.                 Error("Inquiry cancelled by user.");
  103.                 }
  104.         else if (z4_inq.result == Z4_RESULT_NOT_FOUND)
  105.                 {
  106.                 Error("Not found.");
  107.                 }
  108.         else if (z4_inq.result == Z4_RESULT_INV_ST)
  109.                 {
  110.                 Error("Invalid state.");
  111.                 }
  112.         else if (z4_inq.result == Z4_RESULT_INV_CITY)
  113.                 {
  114.                 Error("Invalid city.");
  115.                 }
  116.         else if (z4_inq.result == Z4_RESULT_INV_CSZ)
  117.                 {
  118.                 Error("Invalid City/State or ZIP.");
  119.                 }
  120.         else
  121.                 {
  122.                 AfxMessageBox("Inquiry successful.");
  123.                 }
  124.         return ;
  125. }
  126.  
  127. /////////////////////////////////////////////////////////////////////////////
  128. // CMytestView message handlers
  129.  
  130. void CMytestView::OnLButtonDown(UINT nFlags, CPoint point)
  131. {
  132.  
  133.  
  134.     CString Z4DumpString(const Z4_Z4&);
  135.     
  136.     Initialize();
  137.  
  138.     PCSZ pcszAddr2 = "14917 n st";
  139.     PCSZ pcszCity = "omaha";
  140.     PCSZ pcszState = "ne";
  141.     
  142.    z4_inq.Set(pcszCity, pcszState, "", "", pcszAddr2);
  143.    
  144.    if (z4_inq.Inquiry() )
  145.    {
  146.       if (z4_inq.result != Z4_RESULT_EXACT && z4_inq.result != Z4_RESULT_MULTI)
  147.              SetResults();
  148.                             
  149.    }
  150.        if (z4_inq.result == Z4_RESULT_EXACT) {
  151.                AfxMessageBox(CString ("Matched! ZIP+4 is ") +
  152.                z4_inq.match.rec[0].z4.szZip5 + "-" 
  153.                + z4_inq.match.rec[0].z4.szAddonHi); 
  154.                //+ z4_inq.match.rec[0].z4.szCity);
  155.        } else {
  156.            if (z4_inq.result == Z4_RESULT_MULTI)
  157.            {
  158.                 AfxMessageBox("Multiple Records Matched");
  159.            } else {
  160.                 AfxMessageBox("Not Matched");
  161.            }
  162.        }
  163. }
  164.  
  165.  
  166.  
  167.